﻿using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Text;
using Aga.GestionDeArchivos.Domain.Entities;

namespace Aga.GestionDeArchivos.Storage
{
    public class ClienteRepository : RepositoryBase<Cliente>
    {

        /// <summary>
        /// Initializes a new instance of the <see cref="ClienteRepository"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        public ClienteRepository(AgaEntities context)
            : base(context) { }

        /// <summary>
        /// Adds to context.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        protected override Action<Cliente> AddToContext(Cliente entity)
        {
            return delegate { Context.AddToClientes(entity); };
        }

        /// <summary>
        /// Gets the entity set.
        /// </summary>
        /// <value>The entity set.</value>
        protected override ObjectSet<Cliente> EntitySet
        {
            get { return Context.Clientes; }
        }

        /// <summary>
        /// Gets all clients
        /// </summary>
        /// <returns></returns>
        public override IQueryable<Cliente> GetAll()
        {
            return base.GetAll()
                       .Where(c => !c.Activo.HasValue || c.Activo == true);
        }

    }
}
